<template>
  <div class="members-container">
    <div class="page-header">
      <h1>会员管理</h1>
      <button class="add-button" @click="showAddMemberDialog = true">
        <i class="fa fa-plus"></i>
        添加会员
      </button>
    </div>
    
    <!-- 搜索和筛选 -->
    <div class="search-filter">
      <div class="search-box">
        <i class="fa fa-search"></i>
        <input 
          v-model="searchQuery" 
          type="text" 
          placeholder="搜索用户名、邮箱、手机号"
          @input="handleSearch"
        />
      </div>
      <div class="filter-group">
        <select v-model="filterLevel" @change="handleFilter">
          <option value="">全部等级</option>
          <option value="free">免费用户</option>
          <option value="vip">VIP会员</option>
          <option value="premium">高级会员</option>
        </select>
        <select v-model="filterStatus" @change="handleFilter">
          <option value="">全部状态</option>
          <option value="active">活跃</option>
          <option value="inactive">非活跃</option>
          <option value="suspended">已冻结</option>
        </select>
      </div>
    </div>
    
    <!-- 会员列表 -->
    <div class="members-table-container">
      <table class="members-table">
        <thead>
          <tr>
            <th><input v-model="selectAll" type="checkbox" @change="toggleSelectAll" /></th>
            <th>ID</th>
            <th>头像</th>
            <th>用户名</th>
            <th>邮箱</th>
            <th>手机号</th>
            <th>会员等级</th>
            <th>注册时间</th>
            <th>最后登录</th>
            <th>状态</th>
            <th>操作</th>
          </tr>
        </thead>
        <tbody>
          <tr v-for="member in paginatedMembers" :key="member.id">
            <td><input v-model="selectedMembers" type="checkbox" :value="member.id" /></td>
            <td>{{ member.id }}</td>
            <td class="member-avatar">
              <img :src="member.avatar || '/src/assets/default-avatar.png'" alt="头像" />
            </td>
            <td class="member-username">{{ member.username }}</td>
            <td>{{ member.email }}</td>
            <td>{{ member.phone }}</td>
            <td>
              <span class="level-badge" :class="member.level">
                {{ getLevelText(member.level) }}
              </span>
            </td>
            <td>{{ formatDate(member.registeredAt) }}</td>
            <td>{{ formatDate(member.lastLogin) }}</td>
            <td>
              <span class="status-badge" :class="member.status">
                {{ getStatusText(member.status) }}
              </span>
            </td>
            <td class="action-buttons">
              <button class="view-button" @click="viewMember(member)">
                <i class="fa fa-eye"></i>
                <span>查看</span>
              </button>
              <button class="edit-button" @click="editMember(member)">
                <i class="fa fa-edit"></i>
                <span>编辑</span>
              </button>
              <button class="status-button" :class="member.status" @click="changeStatus(member)">
                <i class="fa fa-power-off"></i>
                <span>{{ getStatusActionText(member.status) }}</span>
              </button>
              <button class="delete-button" @click="deleteMember(member)">
                <i class="fa fa-trash"></i>
                <span>删除</span>
              </button>
            </td>
          </tr>
        </tbody>
      </table>
      
      <!-- 空状态 -->
      <div v-if="filteredMembers.length === 0" class="empty-state">
        <i class="fa fa-search"></i>
        <p>暂无会员数据</p>
      </div>
    </div>
    
    <!-- 分页 -->
    <div v-if="filteredMembers.length > 0" class="pagination">
      <button :disabled="currentPage === 1" @click="currentPage = 1">
        <i class="fa fa-angle-double-left"></i>
      </button>
      <button :disabled="currentPage === 1" @click="currentPage--">
        <i class="fa fa-angle-left"></i>
      </button>
      <span class="page-info">
        第 {{ currentPage }} 页，共 {{ totalPages }} 页
      </span>
      <button :disabled="currentPage === totalPages" @click="currentPage++">
        <i class="fa fa-angle-right"></i>
      </button>
      <button :disabled="currentPage === totalPages" @click="currentPage = totalPages">
        <i class="fa fa-angle-double-right"></i>
      </button>
    </div>
    
    <!-- 添加/编辑会员对话框 -->
    <div v-if="showAddMemberDialog || showEditMemberDialog" class="dialog-overlay" @click="closeDialog">
      <div class="dialog" @click.stop>
        <div class="dialog-header">
          <h3>{{ showEditMemberDialog ? '编辑会员' : '添加会员' }}</h3>
          <button class="close-button" @click="closeDialog">
            <i class="fa fa-times"></i>
          </button>
        </div>
        <div class="dialog-content">
          <form @submit.prevent="submitMemberForm">
            <div class="form-group">
              <label>用户名</label>
              <input 
                v-model="memberForm.username" 
                type="text" 
                required
                placeholder="请输入用户名"
              />
            </div>
            <div class="form-group">
              <label>邮箱</label>
              <input 
                v-model="memberForm.email" 
                type="email" 
                required
                placeholder="请输入邮箱"
              />
            </div>
            <div class="form-group">
              <label>手机号</label>
              <input 
                v-model="memberForm.phone" 
                type="tel" 
                placeholder="请输入手机号"
              />
            </div>
            <div class="form-group">
              <label>会员等级</label>
              <select v-model="memberForm.level" required>
                <option value="free">免费用户</option>
                <option value="vip">VIP会员</option>
                <option value="premium">高级会员</option>
              </select>
            </div>
            <div class="form-group">
              <label>会员到期时间</label>
              <input 
                v-model="memberForm.membershipEndDate" 
                type="datetime-local" 
                :required="memberForm.level !== 'free'"
              />
            </div>
            <div class="form-group">
              <label>头像URL</label>
              <input 
                v-model="memberForm.avatar" 
                type="text" 
                placeholder="请输入头像URL"
              />
            </div>
            <div class="form-group">
              <label>状态</label>
              <select v-model="memberForm.status" required>
                <option value="active">活跃</option>
                <option value="inactive">非活跃</option>
                <option value="suspended">已冻结</option>
              </select>
            </div>
            <div class="form-group">
              <label>备注</label>
              <textarea 
                v-model="memberForm.notes" 
                rows="3"
                placeholder="请输入备注信息"
              ></textarea>
            </div>
            <div class="dialog-footer">
              <button type="button" class="cancel-button" @click="closeDialog">取消</button>
              <button type="submit" class="save-button">{{ showEditMemberDialog ? '更新' : '添加' }}</button>
            </div>
          </form>
        </div>
      </div>
    </div>
    
    <!-- 查看会员详情对话框 -->
    <div v-if="selectedMember" class="dialog-overlay" @click="selectedMember = null">
      <div class="dialog dialog-large" @click.stop>
        <div class="dialog-header">
          <h3>会员详情</h3>
          <button class="close-button" @click="selectedMember = null">
            <i class="fa fa-times"></i>
          </button>
        </div>
        <div class="dialog-content">
          <div class="member-detail">
            <div class="member-header">
              <img :src="selectedMember.avatar || '/src/assets/default-avatar.png'" alt="头像" class="detail-avatar" />
              <div class="member-info">
                <h2>{{ selectedMember.username }}</h2>
                <div class="member-meta">
                  <span class="level-badge" :class="selectedMember.level">
                    {{ getLevelText(selectedMember.level) }}
                  </span>
                  <span class="status-badge" :class="selectedMember.status">
                    {{ getStatusText(selectedMember.status) }}
                  </span>
                </div>
                <div class="member-contact">
                  <div class="contact-item">
                    <i class="fa fa-envelope"></i>
                    <span>{{ selectedMember.email }}</span>
                  </div>
                  <div class="contact-item">
                    <i class="fa fa-phone"></i>
                    <span>{{ selectedMember.phone || '未设置' }}</span>
                  </div>
                  <div class="contact-item">
                    <i class="fa fa-calendar-alt"></i>
                    <span>注册时间：{{ formatDate(selectedMember.registeredAt) }}</span>
                  </div>
                  <div class="contact-item">
                    <i class="fa fa-sign-in-alt"></i>
                    <span>最后登录：{{ formatDate(selectedMember.lastLogin) }}</span>
                  </div>
                  <div v-if="selectedMember.membershipEndDate" class="contact-item">
                    <i class="fa fa-clock"></i>
                    <span>会员到期：{{ formatDate(selectedMember.membershipEndDate) }}</span>
                  </div>
                </div>
              </div>
            </div>
            
            <div class="member-activity">
              <h3>近期活动</h3>
              <div class="activity-list">
                <div v-for="(activity, index) in selectedMember.recentActivities" :key="index" class="activity-item">
                  <i class="fa fa-circle"></i>
                  <div class="activity-content">
                    <div class="activity-text">{{ activity.description }}</div>
                    <div class="activity-time">{{ formatDate(activity.timestamp) }}</div>
                  </div>
                </div>
              </div>
            </div>
            
            <div v-if="selectedMember.notes" class="member-notes">
              <h3>备注信息</h3>
              <p>{{ selectedMember.notes }}</p>
            </div>
          </div>
        </div>
      </div>
    </div>
    
    <!-- 会员统计摘要 -->
    <div class="member-stats">
      <div class="stat-card">
        <div class="stat-icon members-icon"><i class="fa fa-users"></i></div>
        <div class="stat-content">
          <div class="stat-number">{{ members.length }}</div>
          <div class="stat-label">总会员数</div>
        </div>
      </div>
      <div class="stat-card">
        <div class="stat-icon active-icon"><i class="fa fa-user-check"></i></div>
        <div class="stat-content">
          <div class="stat-number">{{ members.filter(m => m.status === 'active').length }}</div>
          <div class="stat-label">活跃会员</div>
        </div>
      </div>
      <div class="stat-card">
        <div class="stat-icon vip-icon"><i class="fa fa-crown"></i></div>
        <div class="stat-content">
          <div class="stat-number">{{ members.filter(m => m.level === 'vip' || m.level === 'premium').length }}</div>
          <div class="stat-label">付费会员</div>
        </div>
      </div>
      <div class="stat-card">
        <div class="stat-icon new-icon"><i class="fa fa-user-plus"></i></div>
        <div class="stat-content">
          <div class="stat-number">{{ newMembersCount }}</div>
          <div class="stat-label">本月新增</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'MembersView',
  data() {
    return {
      // 模拟会员数据
      members: [
        {
          id: 'member001',
          username: '张三',
          email: 'zhangsan@example.com',
          phone: '13800138001',
          level: 'vip',
          status: 'active',
          avatar: '/src/assets/avatar1.jpg',
          registeredAt: '2023-06-15T10:30:00Z',
          lastLogin: '2024-01-10T15:20:00Z',
          membershipEndDate: '2024-06-15T23:59:59Z',
          notes: 'VIP会员，活跃用户',
          recentActivities: [
            { description: '登录系统', timestamp: '2024-01-10T15:20:00Z' },
            { description: '观看了动漫《鬼灭之刃》', timestamp: '2024-01-09T20:15:00Z' },
            { description: '评论了动漫《进击的巨人》', timestamp: '2024-01-08T18:45:00Z' },
          ],
        },
        {
          id: 'member002',
          username: '李四',
          email: 'lisi@example.com',
          phone: '13900139002',
          level: 'premium',
          status: 'active',
          avatar: '/src/assets/avatar2.jpg',
          registeredAt: '2023-08-20T09:15:00Z',
          lastLogin: '2024-01-09T14:30:00Z',
          membershipEndDate: '2024-08-20T23:59:59Z',
          notes: '高级会员，付费用户',
          recentActivities: [
            { description: '登录系统', timestamp: '2024-01-09T14:30:00Z' },
            { description: '收藏了动漫《海贼王》', timestamp: '2024-01-08T21:30:00Z' },
          ],
        },
        {
          id: 'member003',
          username: '王五',
          email: 'wangwu@example.com',
          phone: '13700137003',
          level: 'free',
          status: 'inactive',
          avatar: '/src/assets/logo.png',
          registeredAt: '2023-09-10T16:45:00Z',
          lastLogin: '2023-12-25T11:20:00Z',
          membershipEndDate: null,
          notes: '免费用户，近期不活跃',
          recentActivities: [
            { description: '登录系统', timestamp: '2023-12-25T11:20:00Z' },
            { description: '注册账号', timestamp: '2023-09-10T16:45:00Z' },
          ],
        },
        {
          id: 'member004',
          username: '赵六',
          email: 'zhaoliu@example.com',
          phone: '13600136004',
          level: 'vip',
          status: 'suspended',
          avatar: '/src/assets/logo.png',
          registeredAt: '2023-10-05T13:20:00Z',
          lastLogin: '2024-01-05T19:40:00Z',
          membershipEndDate: '2024-04-05T23:59:59Z',
          notes: '账号因违规被冻结',
          recentActivities: [
            { description: '账号被管理员冻结', timestamp: '2024-01-06T10:30:00Z' },
            { description: '登录系统', timestamp: '2024-01-05T19:40:00Z' },
          ],
        },
        {
          id: 'member005',
          username: '钱七',
          email: 'qianqi@example.com',
          phone: '13500135005',
          level: 'free',
          status: 'active',
          avatar: '/src/assets/logo.png',
          registeredAt: '2024-01-01T08:10:00Z',
          lastLogin: '2024-01-10T09:30:00Z',
          membershipEndDate: null,
          notes: '新注册用户',
          recentActivities: [
            { description: '登录系统', timestamp: '2024-01-10T09:30:00Z' },
            { description: '注册账号', timestamp: '2024-01-01T08:10:00Z' },
          ],
        },
      ],
      searchQuery: '',
      filterLevel: '',
      filterStatus: '',
      selectedMembers: [],
      selectAll: false,
      showAddMemberDialog: false,
      showEditMemberDialog: false,
      selectedMember: null,
      currentPage: 1,
      itemsPerPage: 10,
      memberForm: {
        id: '',
        username: '',
        email: '',
        phone: '',
        level: 'free',
        status: 'active',
        avatar: '',
        registeredAt: new Date().toISOString(),
        lastLogin: new Date().toISOString(),
        membershipEndDate: null,
        notes: '',
        recentActivities: [],
      },
    }
  },
  computed: {
    filteredMembers() {
      let filtered = this.members
      
      // 搜索
      if (this.searchQuery) {
        const query = this.searchQuery.toLowerCase()
        filtered = filtered.filter(member => 
          member.username.toLowerCase().includes(query) || 
          member.email.toLowerCase().includes(query) ||
          (member.phone && member.phone.includes(query)),
        )
      }
      
      // 等级筛选
      if (this.filterLevel) {
        filtered = filtered.filter(member => member.level === this.filterLevel)
      }
      
      // 状态筛选
      if (this.filterStatus) {
        filtered = filtered.filter(member => member.status === this.filterStatus)
      }
      
      return filtered
    },
    paginatedMembers() {
      const start = (this.currentPage - 1) * this.itemsPerPage
      const end = start + this.itemsPerPage
      return this.filteredMembers.slice(start, end)
    },
    totalPages() {
      return Math.ceil(this.filteredMembers.length / this.itemsPerPage)
    },
    newMembersCount() {
      const now = new Date()
      const year = now.getFullYear()
      const month = now.getMonth()
      
      return this.members.filter(member => {
        const regDate = new Date(member.registeredAt)
        return regDate.getFullYear() === year && regDate.getMonth() === month
      }).length
    },
  },
  methods: {
    handleSearch() {
      this.currentPage = 1
    },
    handleFilter() {
      this.currentPage = 1
    },
    toggleSelectAll() {
      if (this.selectAll) {
        this.selectedMembers = this.filteredMembers.map(member => member.id)
      } else {
        this.selectedMembers = []
      }
    },
    formatDate(dateString) {
      if (!dateString) return '无'
      const date = new Date(dateString)
      return date.toLocaleString('zh-CN')
    },
    getLevelText(level) {
      switch (level) {
        case 'free': return '免费用户'
        case 'vip': return 'VIP会员'
        case 'premium': return '高级会员'
        default: return '未知'
      }
    },
    getStatusActionText(status) {
      switch (status) {
        case 'active': return '冻结'
        case 'inactive': return '激活'
        case 'suspended': return '解冻'
        default: return '修改状态'
      }
    },
    getStatusText(status) {
      switch (status) {
        case 'active': return '活跃'
        case 'inactive': return '非活跃'
        case 'suspended': return '已冻结'
        default: return '未知'
      }
    },
    viewMember(member) {
      this.selectedMember = { ...member }
    },
    editMember(member) {
      this.memberForm = { ...member }
      this.showEditMemberDialog = true
    },
    changeStatus(member) {
      const statusOptions = ['active', 'inactive', 'suspended']
      const currentIndex = statusOptions.indexOf(member.status)
      const nextIndex = (currentIndex + 1) % statusOptions.length
      member.status = statusOptions[nextIndex]
    },
    deleteMember(member) {
      if (confirm(`确定要删除会员「${member.username}」吗？此操作不可撤销！`)) {
        const index = this.members.findIndex(m => m.id === member.id)
        if (index > -1) {
          this.members.splice(index, 1)
        }
      }
    },
    closeDialog() {
      this.showAddMemberDialog = false
      this.showEditMemberDialog = false
      this.resetForm()
    },
    resetForm() {
      this.memberForm = {
        id: '',
        username: '',
        email: '',
        phone: '',
        level: 'free',
        status: 'active',
        avatar: '',
        registeredAt: new Date().toISOString(),
        lastLogin: new Date().toISOString(),
        membershipEndDate: null,
        notes: '',
        recentActivities: [],
      }
    },
    submitMemberForm() {
      if (this.showEditMemberDialog) {
        // 编辑会员
        const index = this.members.findIndex(m => m.id === this.memberForm.id)
        if (index > -1) {
          this.members[index] = { ...this.members[index], ...this.memberForm }
        }
      } else {
        // 添加会员
        const newMember = {
          ...this.memberForm,
          id: 'member' + String(this.members.length + 100).padStart(3, '0'),
          registeredAt: new Date().toISOString(),
          lastLogin: new Date().toISOString(),
          recentActivities: [
            { description: '注册账号', timestamp: new Date().toISOString() },
          ],
        }
        this.members.push(newMember)
      }
      
      this.closeDialog()
    },
  },
}
</script>

<style scoped>
.members-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  overflow-x: auto;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 15px;
}

.page-header h1 {
  color: #2c3e50;
  margin: 0;
  font-size: 24px;
}

.add-button {
  background: #3498db;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  transition: background-color 0.3s;
}

.add-button:hover {
  background: #2980b9;
}

.add-button i {
  margin-right: 5px;
}

/* 搜索和筛选 */
.search-filter {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 20px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 300px;
}

.search-box i {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: #95a5a6;
}

.search-box input {
  width: 100%;
  padding: 10px 15px 10px 40px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}

.filter-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-group select {
  padding: 10px 15px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  background: white;
  min-width: 150px;
}

/* 会员统计 */
.member-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  gap: 15px;
  transition: transform 0.3s, box-shadow 0.3s;
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
}

.members-icon {
  background: linear-gradient(135deg, #3498db, #2980b9);
}

.active-icon {
  background: linear-gradient(135deg, #2ecc71, #27ae60);
}

.vip-icon {
  background: linear-gradient(135deg, #e67e22, #d35400);
}

.new-icon {
  background: linear-gradient(135deg, #9b59b6, #8e44ad);
}

.stat-content {
  flex: 1;
}

.stat-number {
  font-size: 28px;
  font-weight: 600;
  color: #2c3e50;
  line-height: 1;
}

.stat-label {
  color: white;
  font-size: 14px;
  margin-top: 5px;
}

/* 会员列表 */
.members-table-container {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  overflow: hidden;
  margin-bottom: 20px;
  overflow-x: scroll;
  min-width: 800px;
}

.members-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1000px;
}

.members-table th,
.members-table td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid #eee;
  white-space: nowrap;
}

.members-table th {
  background: #f8f9fa;
  font-weight: 600;
  color: #2c3e50;
}

.member-avatar img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.member-username {
  font-weight: 500;
}

.level-badge,
.status-badge {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.level-badge.free {
  background: #ecf0f1;
  color: #7f8c8d;
}

.level-badge.vip {
  background: #f39c12;
  color: white;
}

.level-badge.premium {
  background: #e74c3c;
  color: white;
}

.status-badge.active {
  background: #2ecc71;
  color: white;
}

.status-badge.inactive {
  background: #95a5a6;
  color: white;
}

.status-badge.suspended {
  background: #e74c3c;
  color: white;
}

.action-buttons {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.action-buttons button {
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
    display: flex;
    align-items: center;
    gap: 4px;
  }
  
  .action-buttons button span {
    font-size: 12px;
  }

.view-button {
  background: #95a5a6;
  color: white;
}

.view-button:hover {
  background: #7f8c8d;
}

.edit-button {
  background: #3498db;
  color: white;
}

.edit-button:hover {
  background: #2980b9;
}

.status-button.active {
  background: #95a5a6;
  color: white;
}

.status-button.inactive {
  background: #3498db;
  color: white;
}

.status-button.suspended {
  background: #2ecc71;
  color: white;
}

.delete-button {
  background: #e74c3c;
  color: white;
}

.delete-button:hover {
  background: #c0392b;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #95a5a6;
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 15px;
  opacity: 0.5;
}

/* 分页 */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.pagination button {
  padding: 8px 12px;
  border: 1px solid #ddd;
  background: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s;
}

.pagination button:hover:not(:disabled) {
  background: #f8f9fa;
  border-color: #3498db;
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.page-info {
  font-size: 14px;
  color: #666;
}

/* 对话框 */
.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.dialog {
  background: white;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.dialog-large {
  max-width: 800px;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #eee;
}

.dialog-header h3 {
  margin: 0;
  color: #2c3e50;
}

.close-button {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #95a5a6;
}

.dialog-content {
  padding: 20px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
  color: #34495e;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 15px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 30px;
}

.cancel-button,
.save-button {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.3s;
}

.cancel-button {
  background: #ecf0f1;
  color: #7f8c8d;
}

.cancel-button:hover {
  background: #bdc3c7;
}

.save-button {
  background: #3498db;
  color: white;
}

.save-button:hover {
  background: #2980b9;
}

/* 会员详情样式 */
.member-detail {
  padding: 20px;
}

.member-header {
  display: flex;
  gap: 20px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.detail-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
}

.member-info {
  flex: 1;
  min-width: 300px;
}

.member-info h2 {
  color: #2c3e50;
  margin-top: 0;
  margin-bottom: 15px;
}

.member-meta {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

.member-contact {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #7f8c8d;
}

.member-activity {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid #eee;
}

.member-activity h3 {
  color: #2c3e50;
  margin-bottom: 15px;
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.activity-item {
  display: flex;
  gap: 15px;
  align-items: flex-start;
}

.activity-item i {
  font-size: 8px;
  color: #3498db;
  margin-top: 8px;
}

.activity-content {
  flex: 1;
}

.activity-text {
  color: #34495e;
  margin-bottom: 5px;
}

.activity-time {
  font-size: 12px;
  color: #95a5a6;
}

.member-notes {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid #eee;
}

.member-notes h3 {
  color: #2c3e50;
  margin-bottom: 10px;
}

.member-notes p {
  color: #34495e;
  line-height: 1.6;
  white-space: pre-wrap;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .members-container {
    padding: 10px;
  }
  
  .search-filter {
    flex-direction: column;
  }
  
  .filter-group {
    width: 100%;
  }
  
  .filter-group select {
    flex: 1;
  }
  
  .member-stats {
    grid-template-columns: 1fr;
  }
  
  .members-table-container {
    overflow-x: auto;
  }
  
  .members-table {
    display: block;
    overflow-x: auto;
  }
  
  .members-table th,
  .members-table td {
    padding: 8px;
    font-size: 13px;
  }
  
  .action-buttons {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .pagination {
    flex-wrap: wrap;
  }
  
  .member-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  
  .member-info {
    min-width: auto;
  }
}
</style>